;
define(["MComponent","MPTitled"], function(MComponent,MPTitled) {
	
	/**
	 * 手风琴面板
	 * @param {Object} background 背景
	 */
	var MPAccordion = function(background) {
		this.dom = this.query("<div></div>","MPAccordion");
		this.setBackground(background);
		
		//组件集合
		var components = [];
		
		//显示方式
		var display = "VERTICAL";
		
		//动画
		var showAnimate = true;
		
		/**
		 * 添加面板
		 */
		this.addAccordionPanel = function(titledPanel){
			var panel = titledPanel;
			
			if(titledPanel instanceof MPTitled){
				panel = titledPanel;
			}else{
				var tiled = new MPTitled();
				tiled.setTitle(titledPanel);
				panel = tiled;
			}
			components[components.length] = panel;
			this.append(panel);
			
			panel.getContent().transition(["height","width"],1000);
			
			panel.getTitle().handle("click",function(){
				var content = panel.getContent();
				content.dom.css("height",content.getHeight() + "px");
				if(!content.mheight){
					content.mheight = content.getHeight();
					content.dom.css("height",content.mheight + "px");
				}
				if(content.titleIsClick){
					content.setVisible(true);
					content.setHeight(content.mheight);
					content.ieOnSuccess(function(){
						content.setVisible(true);
					});
				}else{
					content.setHeight(0);
					content.ieOnSuccess(function(){
						content.setVisible(false);
					});
				}
				
				if(showAnimate){
					content.start();
				}
				
				content.titleIsClick=!content.titleIsClick;
			});
			return this;
		};
		
		/**
		 * 渲染
		 */
		this.render = function(){
			
		}
		
		this.init();
		
		this.init = function(){
//			this.buildShadow();
		};
		
		this.init();
	};
	mofum.extend(MPAccordion, MComponent);
	return MPAccordion;
});